<div class="right_side_operate_area">
    <div class="right_side_title left">
        <h2>
        <?php 
       // var_dump($user);die;
        echo $user['User']['name'];
        $dan='"';
        ?>
        </h2>
        <?php 
        $currentuser=$session->read('User');
     //   var_dump($currentuser);die;
        if($user['User']['id']!=$currentuser['id'] && $currentuser['isadmin'] && $user['User']['cid'] ==null){
            if($user['User']['isadmin']){
            ?>
            <a class="user_link" href="javascript:void(0)" onclick="return removeadmin('<?php echo $user['User']['id'] ;?>')"><?php echo "移除系统管理员"; ?></a>
        <?php	}else{
            ?>
            <a class="user_link" href="javascript:void(0)" onclick="return makeadmin('<?php echo $user['User']['id'] ;?>')"><?php echo '设置系统管理员'; ?></a>
        <?php	}
        } ?>
     </div>
        
         
         <div class="right item_add_btn"><?php echo $html->link("返回","/users/index/"); ?></div>
         <?php if($currentuser['isadmin'] || $currentuser['id'] == $user['User']['id']){?>
         <div class="right item_add_btn">
         <?php 
         	$upath="/users/edit/".$user['User']['id'];
            if($user['User']['cid']){
            	$upath="/companys/editinfo/".$user['User']['cid'];
            }
        	echo $html->link(__('Edit',true),$upath); 
          ?></div>
         <?php }?>
          <?php if($currentuser['id'] == $user['User']['id']) { ?>
        <div class="right item_add_btn"><?php echo $html->link(__('Change Password',true),"/users/editpassword/".$user['User']['id']); ?></div>
        <?php }?>
        <div class="clear"></div>
   
</div>
<div class="right_side_scollbar">
    <div class="detail_info_panel">
        <div class="user_info_details">
            <div class="user_info_portrait left" style="position:relative;left:330px;">
                <?php  echo $form->hidden('User.id',array('value'=>$user['User']['id'])); ?>
                <?php 
              //  var_dump($attachment);die;
              //  echo $html->image($user["User"]["photo_id"],array("width"=>"150px","height"=>"180px"));
                //$this->Attachment->findById($user["User"]["photo_id"]);
                if($attachment['Attachment']['file_path']!="upload/images/"){
                	$path=Router::url(array('controller' => '/', 'action' =>''), true);
                	?>
                <img alt="" src="<?php echo $path;?>showthumbnail.php?path=<?php echo base64_encode($attachment['Attachment']['file_path']);?>" />
                <?php 
                }else{ echo $html->image('men_large.jpg'); }
                ?>
                <div class="change_portrait">
                <?php if($currentuser['id'] == $user['User']['id'] && 1==2){ ?>
                    <a onclick="toggle()" href="javascript:void(0);">更换头像</a>
                <?php } ?>
                    <div id="photo_file"  style="display:none;">
                      <?php echo $form->create('User', array('action' => 'editphoto','type'=> 'post','id' => 'addform','name' => 'form','enctype'=>'multipart/form-data','onsubmit' => 'return checkpic()')); ?>
                        <?php echo $form->hidden('User.id',array('value'=> $user['User']['id']));?>
                        <input type="file" id="upload" name="upload">
                     <?php echo $form->submit("上传", array("id"=>"addfile","name"=>"submit","class"=>"buttom","div"=>false));?>
                        </form>
                    </div>
                </div>
            </div>
            <div class="user_info_desc left" style="clear:both;position:relative;left:280px;">
                <div class="details_item_line">
                    <div class="details_item">
                        <div class="form_left_title left"><?php echo __('Name') ;?>：</div>
                        <?php if($currentuser['id'] == $user['User']['id'] && 1==2){ ?>
                        <div class="form_right_input left"><?php echo $form->text('User.name',array('value' => $user['User']['name'],'onchange'=>'return changeuser(this,'.$dan.'ncontent'.$dan.')'));?></div>
                        <?php }else{ ?>
                        <div class="form_right_input left"><?php echo $user['User']['name'];?></div>
                        <?php } ?>
                    </div>  
                </div>
                <div class="details_item_line">
                    <div class="details_item">
                        <div class="form_left_title left"><?php echo __('Email') ;?>：</div>
                        <div class="form_right_input left"><?php echo $user['User']['email'];?></div>
                    </div>  
                </div>
                <div class="details_item_line">
                    <div class="details_item">
                        <div class="form_left_title left"><?php echo __('Position') ;?>：</div>
                        <?php if($currentuser['id'] == $user['User']['id'] && 1==2){ ?>
                        <div class="form_right_input left"><?php echo $form->text('User.position',array('value' => $user['User']['position'],'onchange'=>'return changeuser(this,'.$dan.'pcontent'.$dan.')'));?></div>
                        <?php }else{ ?>
                        <div class="form_right_input left"><?php echo $user['User']['position'];?></div>
                        <?php } ?>
                    </div>  
                </div>
                 <?php if($user['User']['cid'] ==null){ ?>
                <div class="details_item_line">
                    <div class="details_item">
                        <div class="form_left_title left"><?php echo "所在部门" ;?>：</div>
                        <div class="form_right_input left"><?php echo $user['User']['group'] ;?></div>
                    </div>  
                </div>
                <?php } ?>
                <div class="details_item_line">
                   <div class="details_item">
                        <div class="form_left_title left"><?php echo __('Mobile') ;?>：</div>
                         <?php if($currentuser['id'] == $user['User']['id'] && 1==2){ ?>
                        <div class="form_right_input left"><?php echo $form->text('User.mobile',array('value' => $user['User']['mobile'],'onchange'=>'return changeuser(this,'.$dan.'tcontent'.$dan.')'));?></div>
                        <?php }else{ ?>
                        <div class="form_right_input left"><?php echo $user['User']['mobile'];?></div>
                        <?php } ?>
                    </div>
                </div>
                <div class="details_item_line">
                   <div class="details_item">
                        <div class="form_left_title left"><?php echo __('Address') ;?>：</div>
                        <?php if($currentuser['id'] == $user['User']['id'] && 1==2){ ?>
                        <div class="form_right_input left"><?php echo $form->text('User.address',array('value'=>$user['User']['address'],'onchange'=>'return changeuser(this,'.$dan.'acontent'.$dan.')'));?></div>
                        <?php }else{ ?>
                        <div class="form_right_input left"><?php echo $user['User']['address'];?></div>
                        <?php } ?>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
var webpath=$("#getpath").attr('href');
function changeuser(obj,content)
{
    var userid = $("#UserId").val();
    var contentvalue = obj.value.trim();
    $.ajax({     	   
            url: webpath+'users/edit?userid='+encodeURI(userid)+'&'+content+'='+encodeURIComponent(contentvalue)+'&r='+Math.round(Math.random()*10000), 
            success:function(data){
                alert(data);
                showmessage("用户信息保存成功");
            }       
         });
    return true;
}
function checkpic(){
    if($("#photo_file :file").val() == ''){
        showmessage('请选择上传图片',"F");
        return false;
    }
}
function makeadmin(userid){
    location.href=webpath+'users/makeadmin/'+userid;
    return false;
}
function removeadmin(userid){
    location.href=webpath+'users/removeadmin/'+userid;
    return false;
}
function toggle(){
    var pfds=$("#photo_file").css("display");
    if(pfds=="none"){
        $("#photo_file").attr("style","");
    }else{
        $("#photo_file").css("display","none");
    }
}
</script>